const Service = require('egg').Service;
class bookauthService extends Service {
    async GetBookDetail(bid, headers, querytoken) {
        const{ctx,logger}=this
        try{
            let res_data =  await ctx.service.curlService.curlPost("api/v1.0/book/getBookDetailForWeb",{
                book_id:bid,
                token:querytoken
            })
            if(res_data.res_code!=1){
                return {rescode:"error","err":"first"}
            }else{
                let data={
                    ip: headers ? headers : "0.0.0.0",
                    token: querytoken ? querytoken : "",
                    book: null
                }
                data = await this.ctx.helper.formatBook(data, res_data.msg, bid);
                var qr_data =  await this.ctx.service.wxService.getTempQrCode("bid_" + bid)
                data.qrcode_url = qr_data.msg.url ? qr_data.msg.url : "";
                return {rescode:2,data:data}
            }
        }catch (err) {
            logger.error("bookauthRouter find error :",err)
            return {rescode:"error","err":"two"}
        }
    }

}
module.exports = bookauthService;
